﻿using CNKI.TPI.Web.Search.Model;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Linq.Expressions;
using System.Text;
using System.Threading.Tasks;

namespace CNKI.TPI.Web.Admin.IBLL
{
    /// <summary>
    /// 单库发布设置Service
    /// </summary>
    public interface ISingleDBPublishService
    {
        /// <summary>
        /// 获得数据库列表
        /// </summary>
        /// <returns>数据库列表</returns>
        IList<SYS_CMS_DATABASE> GetDBList(IList<SearchType> SearchTypeList = null);

        /// <summary>
        /// 根据数据库ID获取SYS_CMS_DATABASE实例
        /// </summary>
        /// <param name="databaseId">数据库ID</param>
        /// <returns>数据库信息</returns>
        SYS_CMS_DATABASE GetDatabaseByID(int databaseId);

        /// <summary>
        /// 获得数据库列表,分页
        /// </summary>
        /// <param name="pageIndexNow">开始位置</param>
        /// <param name="pageSize">长度</param>
        /// <param name="count">返回的列表长度</param>
        /// <param name="type">是否发布状态</param>
        /// <param name="DbName">数据库名称</param>
        /// <param name="SearchTypeList"></param>
        /// <returns>数据库列表</returns>
        IList<SYS_CMS_DATABASE> GetDBListPageSize(int pageIndexNow, int pageSize, string type, string DbName, out int count, IList<SearchType> SearchTypeList = null);
        /// <summary>
        /// 获得数据库字段
        /// </summary>
        /// <param name="dbCode">数据库编码</param>
        /// <returns>数据库字段列表</returns>
        IList<SYS_CMS_DATABASE_FIELD> GetDBField(string dbCode);

        /// <summary>
        /// 获得数据库发布模板信息
        /// </summary>
        /// <returns>模板列表</returns>
        IList<SYS_CMS_PUBLISHTYPE> GetTemplateList();

        ///// <summary>
        ///// 发布数据库
        ///// </summary>
        ///// <param name="dbInfo"></param>
        ///// <param name="fieldList"></param>
        ///// <returns>0代表成功，-1异常，1代表检索发布失败，2排序失败，3概览失败， 4细缆失败</returns>
        //int PublishDB(SYS_CMS_DATABASE dbInfo, IList<SYS_CMS_DATABASE_PUBLISH_FIELD> fieldList);

        /// <summary>
        /// 更新数据库表是否发布字段DatabasePubFlag
        /// </summary>
        /// <param name="DbID">数据库ID</param>
        /// <param name="flag">发布标识，1 发布，0未发布</param>
        /// <returns></returns>
        bool UpdatetDBPubFlag(string DbID, int flag);
        /// <summary>
        /// 更改SYS_CMS_DATABASE_PUBLISH_FIELD表数据
        /// </summary>
        /// <param name="DbID"></param>
        /// <param name="fieldList"></param>
        /// <param name="flage"></param>
        /// <returns></returns>
        bool PublicField(string DbID, IList<SYS_CMS_DATABASE_PUBLISH_FIELD> fieldList, string flage);
        /// <summary>
        /// 获取已经设置的字段
        /// </summary>
        /// <param name="dbID"></param>
        /// <param name="type"></param>
        /// <returns></returns>
        IList<SYS_CMS_DATABASE_PUBLISH_FIELD> GetField(string dbID, FieldType type);

        /// <summary>
        /// 更新数据库表 保存发布形式
        /// </summary>
        /// <param name="DbID">数据库ID</param>
        /// <param name="templateID">模板ID</param>
        /// <param name="visibleFlage">是否显示</param>
        /// <param name="dbsort">排序</param>
        /// <returns></returns>
        bool UpdatetDBTemplate(string DbID, string templateID, string visibleFlage, string dbsort);

        /// <summary>
        /// 保存显示名称
        /// </summary>
        /// <param name="DbID"></param>
        /// <param name="Name"></param>
        /// <param name="DisplayName"></param>
        /// <returns></returns>
        bool UpdatetDBDisplayName(string DbID, string Name, string DisplayName);
        /// <summary>
        /// 更改数据库显示顺序
        /// </summary>
        /// <param name="list"></param>
        /// <returns></returns>
        bool UpdateDBSort(IList<SYS_CMS_DATABASE> list);

        /// <summary>
        /// 根据查询条件获取数据库列表 分页
        /// </summary>
        /// <returns></returns>
        IList<SYS_CMS_DATABASE> GetDBListPageSize(int pageIndexNow, int pageSize, out int count, string name);
        /// <summary>
        /// 获得已经设置关联的数据库
        /// </summary>
        /// <param name="dbCode">dbcode为空时，获取所有数据</param>
        /// <returns></returns>
        IList<SYS_CMS_DATABASE_RELATION> GetDbRelation(string dbCode);
        /// <summary>
        /// 保存关联数据库
        /// </summary>
        /// <param name="list"></param>
        /// <returns></returns>
        bool SaveRelationField(IList<SYS_CMS_DATABASE_RELATION> list);
        /// <summary>
        /// 删除数据库关联数据
        /// </summary>
        /// <param name="dbcode"></param>
        /// <returns></returns>
        bool DeleteRelation(string dbcode);
    }
}
